{include file='public/header' /}



<body>



<div class="x-nav">

      <span class="layui-breadcrumb">

        <a href="">首页</a>

        <a href="">管理员管理</a>

       
        <a><cite>角色列表</cite></a>
      
      </span>

    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">

        <i class="layui-icon" style="line-height:30px">ဂ</i></a>

</div>





<div class="x-body"  style="padding: 0px">



    <table class="layui-hide" id="test" lay-filter="test"></table>

   

</div>



<script type="text/html" id="toolbarDemo">

      <div class="layui-form-item"> 
          <div class="layui-input-inline">
              <button class="layui-btn" onclick="x_admin_show('添加新角色','{:url(\'add\')}')"><i class="layui-icon"></i>添加新角色</button>
          </div>
        <form class="layui-form" action="" lay-filter="search">
        
         <input type="text" name="name"  placeholder="请输入角色名称搜索" autocomplete="off" class="layui-btn layui-btn-primary" style="margin-left: -50px;">

          <div class="layui-inline">
            <button class="layui-btn"  lay-event="searchBarFunc"><i class="layui-icon">&#xe615;</i></button>
          </div>

  </form>
</div>
</script>



<script type="text/html" id="barDemo">

  <div class="layui-btn-group">

      <button type="button" class="layui-btn" lay-event="edit">编辑</button>
    
      <button type="button" class="layui-btn layui-btn-danger" lay-event="del">删除</button>
      
  </div>

</script>





<style type="text/css">

  /*{# 设置table每一行的height #}*/

  .layui-table-cell {

   height: 50px;

   line-height: 50px;

  }

 </style>

<script>

layui.use('table', function(){

  var table = layui.table

  ,form = layui.form;

  //第一个实例

  table.render({

    elem: '#test'

    ,height:'full-100'

    ,title:'角色列表'

    ,url: "{:url('gList')}" //数据接口

    ,page: true //开启分页

    ,limit:30

    ,toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板

    ,cols: [[ //表头

      // {type:'checkbox', fixed: 'left'}


       {field: 'name', title: '角色名称',fixed: 'left'}

      ,{field: 'remark', title: '备注信息'}

      ,{field: 'update_time', title: '更新时间',  sort: true,hide:false}

      ,{fixed: 'right', title:'操作', toolbar: '#barDemo', width:150}

    ]]

  });






  //监听行工具事件

  table.on('tool(test)', function(obj){

    var data = obj.data;

    if(obj.event === 'del'){

      layer.confirm('确定删除？', function(index){

         $.post("{:url('delGood')}",{id:data.id},function (res) {

                if(res == 1){

                     obj.del();

                     layer.msg('删除成功', {icon: 1});

                }else {

                    layer.msg('删除失败!',{icon:0,time:1000});

                }

            })

      });


    } else if(obj.event === 'edit'){

        x_admin_show('编辑角色信息','{:url(\'edit\')}?id='+obj.data.id);

    }
  });



 //头工具栏事件

  table.on('toolbar(test)', function(obj){

         if(obj.event === 'searchBarFunc'){

              var data = form.val('search');
            
              table.reload('test',{
                  url: "{:url('gList')}",

                  page: {
                    curr: 1 //重新从第 1 页开始
                  }

                 ,where: data
                 ,done: function(res, curr, count){
                    form.val('search', data);

                 }
              })


        }

  });

});

</script>







</body>





</html>